﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using AutoMapper;
using FazaDemo.BL.InterfaceDomain;
using FazaDemo.PL.Mapping;
using FazaDemo.ViewModels;

namespace FazaDemo.PL.WebSite.Mvc
{
    public class MvcApplication : HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Mapper.CreateMap<char?, IEnumerable<SelectListItem>>().ConvertUsing<CharEnumSelectListItemsConverter>();
            Mapper.CreateMap<NavCondElement, NavElementViewModel>()
                .ForMember(m => m.NavDropItems, e => e.MapFrom(src => src.FieldDropType))
                .ForMember(m => m.SelectedItemId, e => e.Ignore())
                .ForMember(m => m.ElemEdit, e => e.Ignore());
            Mapper.CreateMap<NavigatorCondition, NavPageViewModel>()
                .ForMember(m => m.NavArea, c => c.MapFrom(src => src.CondElements))
                .ForMember(m => m.SelectedKindId, c => c.Ignore());
            Mapper.AssertConfigurationIsValid();
        }
    }
}
